package Util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisUtil{
    private static JedisPool jedisPool;
    static{
        JedisPoolConfig config = new JedisPoolConfig();
        // 最大活动对象数
        config.setMaxTotal(50);
        // 最大能够保持idel状态的对象数
        config.setMaxIdle(10);
        jedisPool = new JedisPool(config,"localhost",6379);
    }
    public static Jedis getJedis(){
        return jedisPool.getResource();
    }
    public static void close(Jedis j){
        if(j!=null)
            j.close();
    }
}